<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl">
    <link rel="stylesheet" href="/js/plugins/treeview/bootstrap-treeview.min.css" type="text/css">
    <script type="text/javascript" src="/js/plugins/treeview/bootstrap-treeview.min.js"></script>
    <script>
        $(function () {
            $('.lookBtn').click(function () {
                var json = $(this).data('json');
                $.get('/travel/getContent.do',{id:json.id},function (data) {
                    if (data.result) {
                        $('#myModal .modal-body').html(data.result.content);
                        $('#myModal').modal('show');
                    }else {
                        $.messager.alert(data.msg);
                    }
                });
            });
            $('.releaselBtn').click(function () {
                var json = $(this).data('json');
                //当发布时添加系统消息
                $.get('/systemMessage/save.do',{user_id:json.authorId,travel_id:json.id
                    ,content:'亲!你的游记已经发布了>>>'},function (data) {
                    console.log(data);
                });
                $.get('/travel/updateState.do',{id:json.id,state:2},function (data) {
                    if (data.success) {
                        location.reload();
                    }else {
                        $.messager.alert(data.msg);
                    }
                });
            });
            $('.refuseBtn').click(function () {
                var json = $(this).data('json');
                //当拒绝发布时添加系统消息
                $.get('/systemMessage/save.do',{user_id:json.authorId,travel_id:json.id
                    ,content:'亲!你的游记已经被拒绝了>>>'},function (data) {
                    console.log(data);
                });
                $.get('/travel/updateState.do',{id:json.id,state:-1},function (data) {
                    if (data.success) {
                        location.reload();
                    }else {
                        $.messager.alert(data.msg);
                    }
                });
            });
        })
    </script>
</head>
<body>
<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#assign currentMenu = "waitTravel" />
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">游记管理</h1>
                </div>
            </div>
            <form class="form-inline" id="searchForm" action="/travel/waitList.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题">
                </div>
                <div class="form-group">
                    <select class="form-control" id="dept" name="state">
                        <option value="-2">全部</option>
                        <option value="-1">拒绝</option>
                        <option value="1">待发布</option>
                    </select>
                    <script>
                        $("#dept option[value='${qo.state}']").prop("selected", true);
                    </script>
                </div>
                <button id="btn_query" class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>
            <div class="row">
                <table class="table table-striped table-hover">
                    <tr>
                        <th>标题</th>
                        <th>封面</th>
                        <th>地点</th>
                        <th>作者</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                        <#list pageInfo.list as entitry>
                        <tr>
                            <td>${entitry.title}</td>
                            <td><img src="${entitry.coverUrl}" width="50px"></td>
                            <td>${entitry.place.name}</td>
                            <td>${entitry.author.nickName}</td>
                            <td>${entitry.stateName}</td>
                            <td>
                                <a data-json='${entitry.json}'
                                   class="btn btn-info btn-xs lookBtn" href="javascript:">
                                    <span class="glyphicon glyphicon-pencil"></span>查看游记
                                </a>
                                <a data-json='${entitry.json}'
                                   class="btn btn-info btn-xs releaselBtn" href="javascript:">
                                    <span class="glyphicon glyphicon-pencil"></span>发布
                                </a>
                                <a data-json='${entitry.json}'
                                   class="btn btn-info btn-xs refuseBtn" href="javascript:">
                                    <span class="glyphicon glyphicon-remove-circle"></span>拒绝
                                </a>
                            </td>
                        </tr>
                        </#list>
                </table>
                <#include "../common/page.ftl">
            </div>
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" ">
    <div class="modal-dialog" role="document" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">查看内容</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default " data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<style>
    #myModal img{
        width: 100%;
    }
    #myModal .modal-body{
        max-height: 500px;
        overflow-y: auto;
    }
</style>
</body>
</html>